/*
 * 一件趣事、小品、小故事等
 * 包括 作者，正文，资源链接（图片、视频等），创建时间
 * 
 */
package org.kz.shange.models;

import com.htkj.vdr.common.utils.MyDate;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 *
 * @author jineral
 */
@Document(collection = "Fun")
public class Fun {

    @Id
    String id;
    String text;
    String resLink;
    @DBRef
    Author author;
    Date atTime;
    @Transient
    String atTimeStr;

    public Fun() {
    }

    public Fun(Author author, String text, String resLink, Date atTime) {
        this.author = author;
        this.text = text;
        this.resLink = resLink;
        this.atTime = atTime;
    }

    @Override
    public String toString() {
        return "Fun{" + "id=" + id + ", text=" + text + ", resLink=" + resLink + ", atTime=" + atTime + ", atTimeStr=" + atTimeStr + '}';
    }

//<editor-fold defaultstate="collapsed" desc="property">
    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public Date getAtTime() {
        return atTime;
    }

    public void setAtTime(Date atTime) {
        this.atTime = atTime;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getResLink() {
        return resLink;
    }

    public void setResLink(String resLink) {
        this.resLink = resLink;
    }

    public String getAtTimeStr() {

        String dt = MyDate.formatDate(new Date(), "yyyy-MM-dd");
        atTimeStr = MyDate.formatDate(atTime, "yyyy-MM-dd");
        atTimeStr = dt.equals(atTimeStr) ? MyDate.formatDate(atTime, "今天 HH:mm:ss") : atTimeStr;

        return atTimeStr;
    }
//</editor-fold>
}
